package com.fantasy.string;

public class OutString {

	public static void main(String[] args) {
		String sql="insert into imid_daily(imid_nbr,imid_rcp_date,imid_po_nbr, "
				+ "imid_part,imid_ps_nbr,imid_rcvd,imid_pt_desc1,imid_pt_desc2,imid_vd_desc) "
				+ "select a.prh_receiver,a.prh_rcp_date,a.prh_nbr,a.prh_part,a.prh_ps_nbr, "
				+ "a.prh_rcvd,b.pt_desc1,b.pt_desc2,c.ad_name from " 
				+ "ERPTS" + ".prh_hist a, " 
				+ "ERPTS" + ".pt_mstr b, " 
				+ "ERPTS" + ".ad_mstr c, "
				+ "ERPTS" + ".ptp_det d "		/* New Add */
				+ "where a.prh_domain = 'mfg' and b.pt_domain = 'mfg' and b.pt_part = a.prh_part "
				+ "and c.ad_domain = 'mfg' and c.ad_addr = a.prh_vend "
				+ "and d.ptp_domain = 'mfg' and d.ptp_part = a.prh_part and d.ptp_site = a.prh_site and d.ptp_ins_rqd = 'yes' "	/* New Add */
				+ "and not exists (select * from imid_daily "
				+ "where imid_nbr = a.prh_receiver and imid_rcp_date = a.prh_rcp_date) "
				//IQC自2015-01-01之后将编写生成IMI单的规则改变，新的单号前面去掉了字母，将只会有数字
				//+ "and (a.prh_receiver like 'H%' or a.prh_receiver like 'T%') "
				+ "and left(a.prh_receiver, 1) between '0' and '9' " /* New Add(判断IMI单的首字母是否是数字) */
				+ "and TO_DAYS(NOW()) - TO_DAYS(a.prh_rcp_date) <= 30" 
				+ " order by prh_rcp_date desc";
		System.out.println(sql);
	}
}
